package com.liangliang.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liangliang.pojo.UserVisitAction;
import com.liangliang.service.UserVisitActionService;
import com.liangliang.mapper.UserVisitActionMapper;
import com.liangliang.utils.DataSimulator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
* @author 13172
* @description 针对表【user_visit_action】的数据库操作Service实现
* @createDate 2024-07-20 21:02:09
*/
@Service
public class UserVisitActionServiceImpl extends ServiceImpl<UserVisitActionMapper, UserVisitAction>
    implements UserVisitActionService{


    @Autowired
    private UserVisitActionMapper userVisitActionMapper;

    @Override
    public void generateAndInsertData(int numberOfRecords) {

        List<UserVisitAction> userVisitActionList = new ArrayList<>();
        Random random = new Random();

        for (int i = 0; i < numberOfRecords; i++) {
            UserVisitAction action = new UserVisitAction();
            action.setDate(new Date());
            action.setUserId((long) random.nextInt(10000));
            action.setSessionId(UUID.randomUUID().toString());
            action.setPageId((long) random.nextInt(1000));
            action.setActionTime(new Date());
            action.setSearchKeyword("keyword" + random.nextInt(100));
            action.setClickCategoryId((long) random.nextInt(100));
            action.setClickProductId((long) random.nextInt(100));
            action.setOrderCategoryIds("1,2,3");
            action.setOrderProductIds("1,2,3");
            action.setPayCategoryIds("1,2,3");
            action.setPayProductIds("1,2,3");
            action.setCityId((long) random.nextInt(1000));
            userVisitActionList.add(action);
        }

        userVisitActionMapper.insertBatch(userVisitActionList);

    }
}




